#!/usr/bin/env python
# -*- coding: utf-8 -*-

import time
import requests
import json
import os.path
import random

MinLongitudeDegrees = 90.0
MaxLongitudeDegrees = 120.0
MinLatitudeDegrees = 20.0
MaxLatitudeDegrees = 50.0

DegreeLevel = 0.1

def dot_obj(id, latitude, longitude, num):
    return {
            "id": id,
            "num": num,
            "latitude": latitude,
            "longitude": longitude,
            "videoHeight": 800,
            "videoWidth": 800,
            "videoImage": "http://git.oschina.net/lsjustin/iOSAppInstall/raw/master/cover11.jpg",
            "videoTitle": "hello title",
            "videoId": 3,
            "userId": 33,
            "userImage": "http://git.oschina.net/lsjustin/iOSAppInstall/raw/master/2.jpg"
            }

def calculate_data():
    index = 0
    l = []
    cur_latitude = MinLatitudeDegrees
    cur_longitude = MinLongitudeDegrees
    while cur_latitude < MaxLatitudeDegrees:
        cur_latitude += DegreeLevel
        cur_longitude = MinLongitudeDegrees
        while cur_longitude < MaxLongitudeDegrees:
            cur_longitude += DegreeLevel
            index += 1
            if random.random() < 0.01:
                l.append(dot_obj(index, cur_latitude, cur_longitude, 1))
    return l

def main():
    data = calculate_data()
    with open("tourvids3.json", "w") as f:
        f.write(json.dumps({"status": "1", "code": "0", "access": "1", "infoList": data}, indent=2))

if __name__ == '__main__':
    main()
    # push_to_user("OFKZ0EUT-ZNDIEGK5-47W1UG0L-NVKZUHG8")
